package com.ruoyi.zhongkao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zhongkao.domain.ZkCandidateRegistration;
import com.ruoyi.zhongkao.service.IZkCandidateRegistrationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 中考基础信息Controller
 * 
 * @author ruoyi
 * @date 2025-07-16
 */
@Api(tags = "中考-考生报名管理")
@RestController
@RequestMapping("/zhongkao/registrations")
public class ZkCandidateRegistrationController extends BaseController
{
    @Autowired
    private IZkCandidateRegistrationService zkCandidateRegistrationService;

    /**
     * 查询中考基础信息列表
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:registration:list')")
    @GetMapping("/list")
        @ApiOperation("中考考生报名信息管理 - 分页查询列表")
    public TableDataInfo list(ZkCandidateRegistration zkCandidateRegistration)
    {
        startPage();
        List<ZkCandidateRegistration> list = zkCandidateRegistrationService.selectZkCandidateRegistrationList(zkCandidateRegistration);
        return getDataTable(list);
    }

    @PostMapping("upsert")
        @ApiOperation("中考考生报名信息管理 - 插入或更新数据")
    public AjaxResult upsert(@RequestBody ZkCandidateRegistration registration)
    {
        return toAjax(zkCandidateRegistrationService.upsertZkCandidateRegistration(registration));
    }
    /**
     * 导出中考基础信息列表
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:registration:export')")
    @Log(title = "中考基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("中考考生报名信息管理 - 导出数据")
    public void export(HttpServletResponse response, ZkCandidateRegistration zkCandidateRegistration)
    {
        List<ZkCandidateRegistration> list = zkCandidateRegistrationService.selectZkCandidateRegistrationList(zkCandidateRegistration);
        ExcelUtil<ZkCandidateRegistration> util = new ExcelUtil<ZkCandidateRegistration>(ZkCandidateRegistration.class);
        util.exportExcel(response, list, "中考基础信息数据");
    }

    /**
     * 获取中考基础信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:registration:query')")
    @GetMapping(value = "byId/{id}")
        @ApiOperation("中考考生报名信息管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zkCandidateRegistrationService.selectZkCandidateRegistrationById(id));
    }

    /**
     * 获取中考基础信息详细信息
     */
    @GetMapping(value = "byIdNumber/{idNumber}")
        @ApiOperation("中考考生报名信息管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("idNumber") String idNumber)
        {
        return success(zkCandidateRegistrationService.selectZkCandidateRegistrationByIdNumber(idNumber));
    }
    /**
     * 新增中考基础信息
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:registration:add')")
    @Log(title = "中考基础信息", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("中考考生报名信息管理 - 新增数据")
    public AjaxResult add(@RequestBody ZkCandidateRegistration zkCandidateRegistration)
    {
        return toAjax(zkCandidateRegistrationService.insertZkCandidateRegistration(zkCandidateRegistration));
    }

    /**
     * 修改中考基础信息
     */
    //@PreAuthorize("@ss.hasPermi('zhongkao:registration:edit')")
    @Log(title = "中考基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("中考考生报名信息管理 - 修改数据")
    public AjaxResult edit(@RequestBody ZkCandidateRegistration zkCandidateRegistration)
    {
        return toAjax(zkCandidateRegistrationService.updateZkCandidateRegistration(zkCandidateRegistration));
    }

    /**
     * 删除中考基础信息
     */
    @PreAuthorize("@ss.hasPermi('zhongkao:registration:remove')")
    @Log(title = "中考基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
        @ApiOperation("中考考生报名信息管理 - 删除数据")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zkCandidateRegistrationService.deleteZkCandidateRegistrationByIds(ids));
    }
}
